<!--
 * @description 列组件
 * @author: 陈陈
 * @date: 2025/05/09
 * @phone: 18560000860
 * @email: 18560000860@qq.com
 * @company: 济南晨霜信息技术有限公司 /
 * @business: 承接前后端项目的开发
-->
<template>
	<view
		class="pure-col"
		:class="_classes"
		:style="_styles"
	>
		<slot></slot>
	</view>
</template>

<script>
	import commonComponentOptions from "../../config/options";
	export default {
		options: commonComponentOptions
	};
</script>

<script setup>
	import { computed } from "vue";
	import props from "./props";

	// -------------------------------------------------------------------------------- Props
	const _props = defineProps(props);

	// -------------------------------------------------------------------------------- Emits
	const _emits = defineEmits(["onClick"]);

	// -------------------------------------------------------------------------------- Classes
	const _classes = computed(() => {
		const array = [];
		return array;
	});

	// -------------------------------------------------------------------------------- Styles
	const _styles = computed(() => {
		const array = [];

		// 宽度为auto
		if (_props.span === "auto") array.push(`--pure-col-span: auto;`);
		else {
			// 占比
			const span = Number(_props.span);

			// 超过 100 就 flex-grow: 1
			if (span > 100) array.push(`--pure-col-flex-grow: 1;`);
			// 占比小于 100
			else array.push(`--pure-col-span: ${_props.span}%;`);
		}

		// 偏移
		array.push(`--pure-col-offset: ${_props.offset}%;`);

		return array;
	});
</script>

<style scoped lang="scss">
	@import "./style.scss";
</style>
